package com.greatwqs.wmall.message.producer.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.greatwqs.wmall.message.producer.service.KafkaProducerService;

@RestController
public class KafkaTestController {

    private final KafkaProducerService producerService;

    public KafkaTestController(KafkaProducerService producerService) {
        this.producerService = producerService;
    }

    @GetMapping("/send")
    public String sendMessage(@RequestParam String message) {
        producerService.sendMessage(message);
        return "Message sent: " + message;
    }

    @GetMapping("/send-partitioned")
    public String sendMessageToPartitionedTopic(@RequestParam String message) {
        producerService.sendMessageToPartitionedTopic(message);
        return "Message sent to partitioned topic: " + message;
    }
}